package alp.starcode.framework.enums;

/**
 * @author 芊宝宝
 * @create 2021/2/8
 */
public enum  CodeEmun {

    SUCCESS(200,"成功"),
    FAILURE(-1,"失败");

    public Integer code;

    public String message;

    public Object data;

    CodeEmun(Integer code) {
        this.code = code;
    }

    CodeEmun(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    CodeEmun(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    CodeEmun(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage(Integer code){
        for (CodeEmun value : CodeEmun.values()) {
            if (value.getCode()==code){
                return value.getMessage();
            }
        }
        return null;
    }
}
